//
//  expressCell.m
//  A Learning Walk
//
//  Created by dllo on 16/6/15.
//  Copyright © 2016年 战斗民族. All rights reserved.
//

#import "expressCell.h"

#define ConWIDTH self.contentView.frame.size.width
#define ConHEIGHT self.contentView.frame.size.height

@implementation expressCell

-(void)dealloc{
    [_labelT release];
    [_labelR release];
    [_labelN release];
    [_imageD release];
    [_model release];
    [super dealloc];
}
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self creatCell];
    }
    return self;
}
-(void)creatCell{
    
    self.labelT = [[UILabel alloc] init];
    self.labelT.backgroundColor = [UIColor clearColor];
    self.labelT.font = [UIFont systemFontOfSize:20];
    [self.contentView addSubview:self.labelT];
    
    
    self.imageD = [[UIImageView alloc] init];
    self.imageD.backgroundColor = [UIColor redColor];
    [self.contentView addSubview:self.imageD];
    
    self.labelN = [[UILabel alloc] init];
    self.labelN.backgroundColor = [UIColor clearColor];
    [self.contentView addSubview:self.labelN];
    
    self.labelR = [[UILabel alloc] init];
    self.labelR.backgroundColor = [UIColor clearColor];
    [self.contentView addSubview:self.labelR];
    self.labelR.textAlignment = NSTextAlignmentRight;
    
    self.viewL = [[UIView alloc] init];
    self.viewL.backgroundColor = [UIColor grayColor];
    [self.contentView addSubview:self.viewL];
    
    [self.labelT release];
    [self.labelN release];
    [self.labelR release];
    [self.viewL release];
}
-(void)layoutSubviews{
    [super layoutSubviews];
    [self.labelT mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(10);
        make.top.mas_equalTo(15);
        make.width.mas_equalTo(ConWIDTH-20);
        make.height.mas_equalTo(40);
        
    }];
    [self.imageD mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.labelT.mas_bottom).offset(10);
        make.bottom.mas_equalTo(-50);
        make.width.mas_equalTo(_labelT.mas_width);
        make.left.mas_equalTo(_labelT.mas_left);
        
    }];
    [self.labelN mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(_imageD.mas_bottom).offset(10);
        make.left.mas_equalTo(_imageD.mas_left);
        make.bottom.mas_equalTo(-15);
        make.width.mas_equalTo(ConWIDTH/3);
        
    }];
    [self.labelR mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(_imageD.mas_bottom).offset(10);
        make.right.mas_equalTo(_imageD.mas_right);
        make.bottom.mas_equalTo(_labelN.mas_bottom);
        make.width.mas_equalTo(ConWIDTH/3);
    }];
    self.viewL.frame = CGRectMake(0, ConHEIGHT-1, ConWIDTH, 1);
}

-(void)setModel:(expressMo *)model{
    if ((_model != model)) {
        [_model release];
        _model = [model retain];;
    }
    self.labelT.text = _model.title;
    
    [self.imageD sd_setImageWithURL:[NSURL URLWithString:_model.bgimage]];
    self.labelN.text = [NSString stringWithFormat:@"%@人浏览",_model.reviewcount];
    self.labelR.text = _model.createtime;
    
}

@end
